package com.hgg.serviceImpl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.hgg.domain.TProduct;
import com.hgg.utils.WebJsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hgg.dao.TProductMapper;

import com.hgg.service.TProductService;

@Service
public class TProductServiceImp implements TProductService {
	@Autowired
	private TProductMapper tProductMapper;

	@Override
	public int insertBatch(List<Map<String, Object>> list) {
		List<TProduct> products = new ArrayList<>();
		Map urlmap = WebJsonUtil.geturlmap();
		for (Map<String, Object> map : list) {
			TProduct product = new TProduct();
			product.setItemid(map.get("auctionId").toString());
			product.setCategoryid(urlmap.get("catIds").toString());
			product.setProducttitle((String) map.get("title"));
			product.setSmallimages((String) map.get("pictUrl"));
			product.setCoverpic((String) map.get("pictUrl"));
			product.setMarketprice((Double) map.get("reservePrice"));
			product.setFinalprice((Double) map.get("zkPrice"));
			product.setShoptitle((String) map.get("nick"));
			product.setVolume((Integer) map.get("biz30day"));
			product.setItemurl((String) map.get("auctionUrl"));
			product.setDsr(null);
			product.setProvcity(null);
			product.setSellerid(map.get("sellerId").toString());
			product.setUsertype((Integer) map.get("userType"));
			product.setCouponamount(null);
			product.setCouponstartfee(null);
			product.setCouponendtime(null);
			product.setCouponremaincount(null);
			product.setCouponstarttime(null);
			product.setCoupontotalcount(null);
			product.setCreatetime(new Date());
			product.setUpdatetime(null);
			System.out.println(product);
			products.add(product);

		}

		return tProductMapper.insertBatch(products);
	}

}
